package com.algorithm.set;/*
 *@Author:DOWN
 *@Date:2022/2/17 9:54
 *@Comment:
 */

import com.algorithm.link.LinkedList;

public class LinkRealizeSet<E extends Comparable<E>> implements SetInterface<E> {
    private LinkedList<E> list;

    public LinkRealizeSet() {
        list = new LinkedList<>();
    }

    @Override
    public void add(E e) {
        if (!contains(e)) {
            list.addFirst(e);
        }
    }

    @Override
    public void remove(E e) {
        list.removeElenment(e);
    }

    @Override
    public boolean contains(E e) {
        return list.contains(e);
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }
}
